package com.stars.empoly.model;

import android.os.Parcel;
import android.os.Parcelable;

import com.stars.empoly.config.ConfigMMKV;
import com.trailer.base.inter.IModel;
import com.trailer.base.inter.IUser;
import com.trailer.base.utils.MMKVManager;

import org.jetbrains.annotations.Nullable;

public class User implements IUser, Parcelable, IModel {



    public String id;
    public String balance;
    public String headImage;
    public String nickname;
    public String number;


    protected User(Parcel in) {
        id = in.readString();
        balance = in.readString();
        headImage = in.readString();
        nickname = in.readString();
        number = in.readString();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(id);
        dest.writeString(balance);
        dest.writeString(headImage);
        dest.writeString(nickname);
        dest.writeString(number);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<User> CREATOR = new Creator<User>() {
        @Override
        public User createFromParcel(Parcel in) {
            return new User(in);
        }

        @Override
        public User[] newArray(int size) {
            return new User[size];
        }
    };

    @Nullable
    public static User get() {
        return MMKVManager.instance().decodeParcelable(ConfigMMKV.USER, User.class);
    }

    @Override
    public boolean save() {
        return MMKVManager.instance().encode(ConfigMMKV.USER, this);
    }


    @androidx.annotation.Nullable
    @Override
    public String avatar() {
        return headImage;
    }
}
